package com.aso114.project.mvp.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aso114.project.R;
import com.aso114.project.base.BaseSimpleActivity;
import com.aso114.project.bean.NeednoticeBean;
import com.aso114.project.mvp.model.CallBack;
import com.aso114.project.mvp.model.CommentModel;
import com.aso114.project.util.Helper;
import com.aso114.project.util.SystemBarHelper;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 须知各个板块点进去的说明
 */
public class NeedNoticeDetailActivity extends BaseSimpleActivity {
    @BindView(R.id.layout_title_bar_back_iv)
    ImageView layoutTitleBarBackIv;
    @BindView(R.id.layout_title_bar_title_tv)
    TextView layoutTitleBarTitleTv;
    Intent intent;
    @BindView(R.id.concetstex)
    TextView concets;
    Dialog dialog;
    @BindView(R.id.title_top_ly)
    RelativeLayout titleTopLy;

    @Override
    protected int getResouseId() {
        return R.layout.neednotice;
    }

    @Override
    protected void initView() {
        SystemBarHelper.immersiveStatusBar(this, 0);
        SystemBarHelper.setHeightAndPadding(this, titleTopLy);
        Intent i = getIntent();
        String val = i.getStringExtra("type");

        if (val.equals("1")) {
            layoutTitleBarTitleTv.setText("考试简介");
        }
        if (val.equals("2")) {
            layoutTitleBarTitleTv.setText("报名时间");
        }
        if (val.equals("3")) {
            layoutTitleBarTitleTv.setText("考试时间");
        }
        if (val.equals("4")) {
            layoutTitleBarTitleTv.setText("考试资料");
        }
        if (val.equals("5")) {
            layoutTitleBarTitleTv.setText("报考条件");
        }

        if (val.equals("6")) {
            layoutTitleBarTitleTv.setText("报考程序");
        }

        if (val.equals("7")) {
            layoutTitleBarTitleTv.setText("考试内容");
        }
        if (val.equals("8")) {
            layoutTitleBarTitleTv.setText("体检考察");
        }
        if (val.equals("9")) {
            layoutTitleBarTitleTv.setText("名单公示");
        }
        if (val.equals("10")) {
            layoutTitleBarTitleTv.setText("用户注册协议");
        }

        final View dialogview = this.getLayoutInflater().inflate(
                R.layout.loading_view, null);
        dialog = new Dialog(this, R.style.dialogStyle);
        dialog.setContentView(dialogview, new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        dialog.getWindow().setGravity(Gravity.CENTER);
        // 设置点击外围解散
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);//设置是否可以按退回键取消
        dialog.show();

        CommentModel.getInstant().getneedcontect(val, new CallBack() {
            @Override
            public void onSuccess(Object o, boolean isSuccess, String msg) {
                dialog.cancel();
                Helper.gotoLogin(isSuccess);//token失效去重新登陆
//                bannerList = (List<BannerBean>)o;
                NeednoticeBean data = (NeednoticeBean) o;

                concets.setText(Html.fromHtml(data.getContent()));
                layoutTitleBarTitleTv.setText(data.getTitle());
            }

            @Override
            public void onFailure(String fail) {
                dialog.cancel();
            }
        });
//
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void getBroadcast(Context context, Intent intent) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.layout_title_bar_back_iv, R.id.layout_title_bar_title_tv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_title_bar_back_iv:
                finish();
                break;
            case R.id.layout_title_bar_title_tv:
                break;
        }
    }
}
